/*
** tools.c for malloc in /home/seth/malloc/tmp1
** 
** Made by kevin lansel
** Login   <lansel_k@epitech.net>
** 
** Started on  Wed Feb  6 13:04:51 2013 kevin lansel
** Last update Fri Feb  8 13:41:38 2013 florian dewulf
*/

#include	<stdio.h>
#include	<unistd.h>
#include	"malloc.h"

extern	t_malloc *g_list;

void		show_alloc_mem()
{
  t_malloc	*test;

  test = g_list;
  printf("break : %p\n", sbrk(0));
  while (test)
    {
      if (test->state)
	printf("%p - %p : %d\n", test + 1, (void *)(test + 1) + test->size, test->size);
      test = test->next;
    }
}

void		*tool_where(t_malloc *tmp, unsigned int size)
{
  t_malloc	*old;

  old = (void *)(tmp + 1) + size;
  old->next = tmp->next;
  old->prev = tmp;
  if (tmp->next)
    tmp->next->prev = old;
  tmp->next = old;
  old->state = FALSE;
  tmp->state = TRUE;
  old->size = tmp->size - (size + BLOCK);
  tmp->size = size;
  return (tmp);
}
